// g++ detect.cpp -o detect -std=c++14 -fsanitize=address -O2 -Wall -Wextra
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF 0x3f3f3f3f3f3f3f3f
template<typename T> void up(T &x, T y) { x = (x > y ? x : y); }
template<typename T> void down(T &x, T y) { x = (x < y ? x : y); }
#define rep(i, a, b) for(int i = (a), i##END = (b); i <= (b); i++)
#define Rep(i, a, b) for(int i = (a), i##END = (b); i >= (b); i--)
#define N ((int)(1e5 + 15))
#define M ((int)(1e6 + 15))

int n, m, L, V, ans1, ans2, p[N], f[N], sum[M];
struct car { int l, r, v, a, ok = false; } a[N];
bool cmp(const car &a, const car &b) { 
    return (a.r == b.r) ? a.l < b.l : a.r < b.r;
}
void clear()
{
    ans1 = ans2 = 0;
    rep(i, 0, m + 5) f[i] = INF;
    rep(i, 0, L + 5) sum[i] = 0;
}
int col[N];
void check()
{
    int tmp = 0;
    rep(i, 0, L + 5) sum[i] = 0;
    rep(i, 1, m) if(col[i]) { ++sum[p[i]], ++tmp; }
    rep(i, 1, L) sum[i] += sum[i - 1];
    rep(i, 1, n)
    {
        if(a[i].ok) continue;
        if(!(sum[a[i].r] - sum[a[i].l - 1])) return;
    }
    up(ans2, m - tmp);
}
void dfs(int x)
{
    if(x == m + 1)
    {
        check();
        return;
    }
    col[x] = 0; dfs(x + 1);
    col[x] = 1; dfs(x + 1);
}
void solve()
{
    cin >> n >> m >> L >> V; clear(); 
    rep(i, 1, n)
    {
        cin >> a[i].l >> a[i].v >> a[i].a;
        if(a[i].a == 0)
        { 
            a[i].r = L;
            if(a[i].v <= V) { a[i].ok = true; ++ans1; }
        }else
        {
            double x = (V * V - a[i].v * a[i].v) / (2.0 * a[i].a);
            if(x < 0)
            {
                if(a[i].a < 0) { a[i].r = a[i].l, a[i].ok = true; ++ans1; }
                else { a[i].l = max(0ll, a[i].l - (int)(x)); a[i].r = L; }
            }
            else
            {
                if(a[i].a < 0) { a[i].r = min(L, a[i].l + (int)(x)); }
                else { a[i].l = min(L, a[i].l + (int)(x + 0.5)), a[i].r = L; }
            }
        }
    }
    // rep(i, 1, n) cout << a[i].l << ' ' << a[i].r << ' ' << a[i].ok << '\n';
    rep(i, 1, m) { cin >> p[i], ++sum[p[i]]; }
    rep(i, 1, L) sum[i] += sum[i - 1];
    sort(a + 1, a + 1 + n, cmp); int j = 1;
    rep(i, 1, n)
    {
        if(a[i].ok) continue;
        if(!(sum[a[i].r] - sum[a[i].l - 1])) { a[i].ok = true; ++ans1; }
    }
    // rep(i, 1, n) cout << a[i].l << ' ' << a[i].r << ' ' << a[i].ok << '\n';
    cout << n - ans1 << ' ';
    if(m <= 20)
    {
        int o = 0; rep(i, 1, n) if(!a[i].ok) a[++o] = a[i];
        n = o;
        dfs(1); cout << ans2 << '\n';
    }else
    {
        j = 1; f[0] = 0;
        int o = 0; rep(i, 1, n) if(!a[i].ok) a[++o] = a[i];
        n = o;
        rep(i, 1, m)
        {
            f[i] = f[i - 1] + 1;
            while(j <= n && a[j].r < p[i]) ++j;
            int l = a[j - 1].l;
            if(j > n) { f[i] = f[i - 1]; continue; }
            if(a[j].r == p[i])
            {
                for(int k = 1; k < i; k++)
                    if(p[k] >= l) f[i] = min(f[i], f[k] + 1);
            }
            while(j <= n && a[j].r == p[i]) ++j;
        }
        cout << f[m] << '\n';
        // rep(i, 1, m) cout << f[i] << " \n"[i == m];
    }
}
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    // freopen("check.in", "r", stdin);
    // freopen("check.out", "w", stdout);
    
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    int qwq; cin >> qwq; while(qwq--) solve();
    return 0;
}
// I love Physics. 